package cloud.daodao.storm.user.controller;

import cloud.daodao.storm.common.model.PageData;
import cloud.daodao.storm.common.model.PageParam;
import cloud.daodao.storm.common.model.Request;
import cloud.daodao.storm.common.model.Response;
import cloud.daodao.storm.common.user.api.PermissionApi;
import cloud.daodao.storm.common.user.model.permission.PermissionData;
import cloud.daodao.storm.common.user.model.permission.PermissionSearch;
import cloud.daodao.storm.common.user.model.permission.PermissionSelect;
import cloud.daodao.storm.common.user.model.permission.PermissionUpsert;
import cloud.daodao.storm.user.service.PermissionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DaoDao
 */
@RestController
public class PermissionController implements PermissionApi {

    @Resource
    private PermissionService permissionService;

    @Override
    public Response<PermissionData> permissionSelect(Request<PermissionSelect> request) {
        PermissionData data = permissionService.permissionSelect(request.getParam());
        return new Response<>(data);
    }

    @Override
    public Response<PermissionData> permissionUpsert(Request<PermissionUpsert> request) {
        PermissionData data = permissionService.permissionUpsert(request.getParam());
        return new Response<>(data);
    }

    @Override
    public Response<PageData<PermissionData>> permissionSearch(Request<PageParam<PermissionSearch>> request) {
        PageData<PermissionData> data = permissionService.permissionSearch(request.getParam());
        return new Response<>(data);
    }

}
